package com.catutlis.myapplication.Utils.SqlLiteUtils;

import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

import com.catutlis.myapplication.Utils.LogHelper;

public class SqliteManger {
    private static SqliteHelper helper;

    public static SqliteHelper GetIntance(Context context) {

        if (helper == null) {
            helper = new SqliteHelper(context);

        }
        return helper;
    }
    //查询数据
    public static void SelectSql(SQLiteDatabase sqLiteDatabase,String Sql){
        if (sqLiteDatabase == null || Sql == null || "".equals(Sql))
            return;
        try {


            Cursor cur = sqLiteDatabase.rawQuery(Sql, new String[]{});

            while(cur.moveToNext()){

                String name = cur.getString(cur.getColumnIndex(SqliteConstant.ID));
                String password = cur.getString(cur.getColumnIndex(SqliteConstant.First));

               LogHelper.PrintLog(name);
                LogHelper.PrintLog(password);

            }


            cur.close();
            sqLiteDatabase.close();
        } catch (SQLException e) {
            LogHelper.PrintLog(e.getMessage());
        }



        return ;
    }
    public static void ExecSQL(SQLiteDatabase sqLiteDatabase, String sql) {
        if (sqLiteDatabase == null || sql == null || "".equals(sql))
            return;
        try {
            sqLiteDatabase.execSQL(sql);
            sqLiteDatabase.close();
        } catch (SQLException e) {
            Log.d("log", e.getMessage());
        }


    }
}
